<template>
  <el-dialog :visible.sync="show" title="修改信息" width="30%">
    <div class="hidden-sm-and-down">
      <el-form ref="elForm" :model="updateForm" :rules="rules" label-width="100px" size="medium">
        <el-form-item label="昵称" prop="nickName">
          <el-input v-model="updateForm['nickName']" style="width: 100%"
                    clearable placeholder="请输入昵称">
          </el-input>
        </el-form-item>
        <el-form-item label="年级" prop="phonenumber">
          <el-input v-model="updateForm['phonenumber']" style="width: 100%"
                    clearable placeholder="请输入年级">
          </el-input>
        </el-form-item>
        <el-form-item label="真实姓名" prop="realname">
          <el-input v-model="updateForm['realname']" style="width: 100%"
                    clearable placeholder="请输入真实姓名">
          </el-input>
        </el-form-item>
        <el-form-item label="性别" prop="sex">
          <el-input v-model="updateForm['sex']" style="width: 100%"
                    clearable placeholder="请输入性别">
          </el-input>
        </el-form-item>
        <!-- <el-form-item  label="学号"  prop="schoolcode">
            <el-input v-model="updateForm['schoolcode']" style="width: 100%"
                      clearable placeholder="请输入学号">
            </el-input>
        </el-form-item>
        <el-form-item  label="学校"  prop="school">
            <el-input v-model="updateForm['school']" style="width: 100%"
                      clearable placeholder="请输入学校">
            </el-input>
        </el-form-item> -->
        <el-form-item size="large">
          <el-button type="primary" @click="submitForm">提交</el-button>
          <el-button @click="resetForm">重置</el-button>
          <el-button type="primary" @click="t_wxuserinfoUpdateClose">取消</el-button>
          <br>
          <span style="color: #00ffff;">{{ message }}</span>
        </el-form-item>
      </el-form>
    </div>
  </el-dialog>
</template>
<script>
import {updateT_Wxuserinfo} from "@/api/t_wxuserinfoServer";

export default {
  name: 't_wxuserinfoUpdate',
  components: {},
  data() {
    return {
      show: false,
      updateForm: {
        "id": null,
        "openid": null,
        "nickName": null,
        "avatarUrl": null,
        // "registerDate":null,
        // "lastLoginDate":null,
        "phonenumber": null,
        "realname": null,
        "sex": null,
        // "schoolcode":null,
        // "school":null,
      },
      msg: {
        "id": null,
        "openid": null,
        "nickName": null,
        "avatarUrl": null,
        "registerDate": null,
        "lastLoginDate": null,
        "phonenumber": null,
        "realname": null,
        "sex": null,
        "schoolcode": null,
        "school": null,
      },
      message: '',
      id: 0,
      rules: {},
    }
  },
  computed: {},
  mounted() {
    this.$bus.$on('t_wxuserinfoUpdateOpen', this.t_wxuserinfoUpdateOpen)      // 显示更新会话
    this.$bus.$on('t_wxuserinfoUpdateClose', this.t_wxuserinfoUpdateClose)    // 关闭更新会话
  },
  beforeCreate() {
    this.$bus.$off('t_wxuserinfoUpdateOpen')
    this.$bus.$off('t_wxuserinfoUpdateClose')
  },
  methods: {
    //提交成功提示
    open1() {
      this.$notify({
        title: '成功',
        message: '修改成功',
        type: 'success'
      });
    },
    t_wxuserinfoUpdateOpen(msg) {
      this.msg = msg
      this.resetForm()
      this.show = true
    },
    t_wxuserinfoUpdateClose() {
      this.show = false
    },
    // 提交表单
    submitForm() {
      updateT_Wxuserinfo(this.updateForm).then(response => {
        response    // 处理响应
        // 更新成功，提交表格
        this.$bus.$emit('t_wxuserinfoUpDataTable')
        this.open1()
      })
    },
    // 重置表单
    resetForm() {
      this.updateForm.id = this.msg["id"]
      this.updateForm.openid = this.msg["openid"]
      this.updateForm.nickName = this.msg["nickName"]
      this.updateForm.avatarUrl = this.msg["avatarUrl"]
      // this.updateForm.registerDate = this.msg["registerDate"]
      // this.updateForm.lastLoginDate = this.msg["lastLoginDate"]
      this.updateForm.phonenumber = this.msg["phonenumber"]
      this.updateForm.realname = this.msg["realname"]
      this.updateForm.sex = this.msg["sex"]
      // this.updateForm.schoolcode = this.msg["schoolcode"]
      // this.updateForm.school = this.msg["school"]
    },
  }
}
</script>
<style>
.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}
</style>
